package com.globallogic.vkulyk.SSHTool;

import org.junit.*;
import java.util.*;

public class Unit_XMLHandler extends SSHToolTester {

	private static final String PARSED_DATA_NOT_EQUALS = "Parsed data not equals";

	@Before
	public void setup() {
		setVarsFromPropertiesFile("testData/testing.properties");
	}

	@Test
	public void shouldGetCorrectDataFromXML_whenCallParseXML() {
		// given
		List<SocketDataKeeper> socketsExpected = new ArrayList<SocketDataKeeper>();
		socketsExpected.add(new SocketDataKeeper(host, port));
		socketsExpected.add(new SocketDataKeeper(host, port));
		List<ActionDataKeeper> actionsExpected = new ArrayList<ActionDataKeeper>();
		actionsExpected.add(new CommandExecutionDataKeeper("execute_command",
				user, password, command));
		actionsExpected.add(new FileCopyDataKeeper("put", user, password,
				srcFileForPut, dstDirForPut));
		actionsExpected.add(new FileCopyDataKeeper("get", user, password,
				srcFileForGet, dstDirForGet));
		actionsExpected.add(new ScriptExecutionDataKeeper("execute_script",
				user, password, script));
		SocketsAndActionsDataKeeper expectedSocketsAndActionsData = new SocketsAndActionsDataKeeper(
				socketsExpected, actionsExpected);

		// when
		SocketsAndActionsDataKeeper actualSocketsAndActionsData = new XMLHandler(
				targetsFile, target).parseXML();

		// then
		Assert.assertEquals(PARSED_DATA_NOT_EQUALS,
				actualSocketsAndActionsData, expectedSocketsAndActionsData);
	}

}
